package com.want.repository;

import com.want.models.entity.UserRole;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @author WangZhiJian
 * @since 2021/11/21
 */
@Repository
public interface UserRoleRepository extends ReactiveSortingRepository<UserRole, Integer> {


    @Query("select a.name ,a.id role_id,b.uid uid from user_role b left join role a on a.id = b.role_id where b.uid in (:uid)")
    <T> Flux<T> findByUid(List<Integer> uid, Class<T> clazz);

    Mono<Void> deleteByUid(Integer uid);
}
